package com.trkj.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.trkj.pojos.YzrMedOutstockDet;
import com.trkj.service.YzrDrawService;
import com.trkj.service.YzrOutStockService;
import com.trkj.vo.Result;
import com.trkj.vo.YzrMedDrawVo;
import com.trkj.vo.YzrMedOutstockVo;

@Controller
public class YzrOutStockController {

	@Autowired
	private YzrOutStockService yzrOutStockService;
	@Autowired
	private YzrDrawService yzrDrawService;
	
	@RequestMapping("/to_outstockYzr")
	public String toOutStock(){
		return "yzr_outstock";
	}
	
	@RequestMapping("/to_pharStoreYzr")
	public String toPharStore(){
		return "yzr_pharStore";
	}
	
	
	//查询出‘未提领’且审批‘已通过’的提领单
	@RequestMapping("/queryDrawByDrawStateYzr")
	public @ResponseBody List<YzrMedDrawVo> queryDrawByDrawState(){
		return yzrDrawService.queryDrawByDrawState();
	}
	
	//提交出库数据 
	@RequestMapping("/addOutstockYzr")
	public @ResponseBody Result addOutstock(String drawId,String kind,String ckr,String tlr){
		yzrOutStockService.addOutstock(drawId, kind, ckr, tlr);
		return new Result();
	}
	
	//分页查询药房库存
	@RequestMapping("/queryAllByPageYzr")
	public @ResponseBody Map<String,Object> queryAllByPage(int page, int rows){
		return yzrOutStockService.queryAllByPage(page, rows);
	}
	
	@RequestMapping("/queryMedByMedNameYzr")
	public @ResponseBody Map<String,Object> queryMedByMedName(String medName,int page, int rows){
		return yzrOutStockService.queryMedByMedName(medName, page, rows);
	}
	
	//分页查询出库信息
	@RequestMapping("/queryAllOutstockYzr")
	public @ResponseBody Map<String,Object> queryAllOutstock(int page, int rows){
		return yzrOutStockService.queryAllOutstock(page, rows);
	}
	
	//根据出库id查询出库信息
	@RequestMapping("/queryOutstockByIdYzr")
	public @ResponseBody YzrMedOutstockVo queryOutstockById(String outstockId){
		return yzrOutStockService.queryOutstockById(outstockId);
	}
	
	//根据出库id查询出库详情信息
	@RequestMapping("/queryOutstockByOutIdYzr")
	public @ResponseBody List<YzrMedOutstockDet> queryOutstockByOutId(String outstockId){
		return yzrOutStockService.queryOutstockByOutId(outstockId);
	}
}
